package View;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import java.io.Serializable;
import java.awt.Font;

/** this class create the GUI in order to Handle new sale 
 * the salesman gets his list of customers in this view 
 */
public class HandleNewSaleView extends JFrame implements Serializable  {
	/** Required fields and attributes **/
	private static final long serialVersionUID = 42L; 
	public JTextField SaleIdField;
	JButton getCustomersBtn;
	 JButton BackBtn;
	
	 /**
	 * default and only constructor
	 */
	public HandleNewSaleView() {
		getContentPane().setLayout(null);
		this.setTitle("Handle New Sale");
		this.setSize(436, 365);
		this.setLocationRelativeTo(null); 
		this.setResizable(false);
		
		JLabel lblInsertSaleId = new JLabel("   Insert  Sale  ID");
		lblInsertSaleId.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblInsertSaleId.setBounds(123, 25, 189, 30);
		getContentPane().add(lblInsertSaleId);
		
		getCustomersBtn = new JButton("Get Sale Customers List");
		getCustomersBtn.setFont(new Font("Tahoma", Font.BOLD, 18));
		getCustomersBtn.setBounds(72, 126, 263, 95);
		getContentPane().add(getCustomersBtn);
		
		SaleIdField = new JTextField();
		SaleIdField.setBounds(102, 55, 198, 60);
		getContentPane().add(SaleIdField);
		SaleIdField.setColumns(10);
		
		BackBtn = new JButton("Back");
		BackBtn.setFont(new Font("Tahoma", Font.BOLD, 14));
		BackBtn.setBounds(154, 232, 89, 23);
		getContentPane().add(BackBtn);
	}
	
	/**
	 * 
	 * @return button getCustomersBtn
	 */
    public JButton getCustomersBtn()
    {
  	  return this.getCustomersBtn;
    }
    
   /**
    * 
    * @return button BackBtn
    */
    public JButton getBackBtn()
    {
  	  return this.BackBtn;
    }
    
    /**
     * add listeners to submit and back button
     * @param actionListener
     */
	public void addHandleNewSaleListeners(ActionListener actionListener){
		
		getCustomersBtn.addActionListener(actionListener);
		BackBtn.addActionListener(actionListener);
	}
	
	/**
	 * 
	 * @return text field SaleIdField
	 */
	public String getSaleRepId()
	{
		return SaleIdField.getText();
	}
	/**
	 * clear the field SaleIdField
	 */
	public void clearFields()
	{
		SaleIdField.setText("");
	}
	
	public void showWindow(){
		setVisible(true);
	}
	public void hideWindow(){
		setVisible(false);
	}
	
}